home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / ascii.enc < prev    next >
Text File  |  1995-03-23  |  6KB  |  146 lines

  1. Article 1021 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!hp-pcd!hpcvra!billw
  3. From: billw@hpcvra.CV.HP.COM (William C Wickes)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: HP 48 Object Encoding
  6. Message-ID: <25590046@hpcvra.CV.HP.COM>
  7. Date: 17 Aug 90 22:27:42 GMT
  8. Organization: Hewlett-Packard Co., Corvallis, OR, USA
  9. Lines: 133
  10.  
  11.  
  12.                       ASCII Encoding HP 48SX Objects
  13.  
  14. Sending an HP 48SX object via electronic mail can be difficult if the
  15. object does not have an ASCII form, such as is the case for library
  16. objects.  There are various encoding schemes available on different
  17. computer systems, but these require that the sender and receiver have
  18. similar computers, or at least compatible encode/decode schemes.  The
  19. programs listed below perform the encoding and decoding on the HP 48SX itself,
  20. which has the advantage of being completely independent of any computer.
  21.  
  22. The programs are nominally called \->ASC and ASC\->.  The former takes an
  23. object from the stack and converts it to a string, in which each nibble of the
  24. object and its checksum is converted to a character 0-9 or A-F.  (The object
  25. must be in RAM, otherwise a "ROM Object" error is returned.)  For sake of easy
  26. inclusion in email letters, the string is broken up by linefeed characters
  27. after every 64 characters.
  28.  
  29. ASC\-> is the inverse of \->ASC: it takes a string created by \->ASC and
  30. converts it back into an object.  When you transmit the encoded strings,
  31. be sure not to change the string; ASC\-> uses the checksum encoded in the
  32. string to verify that the decoding is correct.  An "Invalid String" error
  33. is returned if the result object does not match the original object
  34. encoded by \->ASC.  When you upload a string to your computer, use HP 48
  35. translate mode 3 so that the HP 48 will convert any CR/LF's back to LF's
  36. when the string is later downloaded.
  37.  
  38. Two versions of ASC\-> are included here.  The first (P1) is in HP 48 user
  39. language, using SYSEVALs to execute system objects.  P2 is a
  40. string that the setup program uses P1 to decode into an executable
  41. ASC\->--then P1 is discarded.  The second version is more
  42. compact than the first, and also uneditable and therefore safer (but it can't
  43. be transmitted in ASCII form, which helps to make the point of this exercise).
  44.  
  45. Here are the programs, contained in a directory:
  46.  
  47. (start)
  48. %%HP: T(3)A(D)F(.);
  49. DIR
  50. P1              @ ASC\-> Version 1.
  51. \<<
  52.   IF DUP TYPE 2 \=/
  53.   THEN "Not A String" DOERR
  54.   END RCWS \-> ws
  55.   \<< 16 STWS
  56.     #0 NEWOB SWAP DUP SIZE
  57.     IF DUP 4 <
  58.     THEN DROP SWAP DROP "Invalid String" DOERR
  59.     END 
  60.     DUP 65 / IP - 4 - # 18CEAh SYSEVAL 
  61.     "" OVER # 61C1Ch SYSEVAL
  62.     SWAP # 6641F8000AF02DCCh
  63.     # 130480679BF8CC0h # 518Ah SYSEVAL
  64.     # 19610313418D7EA4h # 518Ah SYSEVAL
  65.     # 7134147114103123h # 518Ah SYSEVAL
  66.     # 5F6A971131607414h # 518Ah SYSEVAL
  67.     # 12EA1717EA3F130Ch # 518Ah SYSEVAL
  68.     # 280826B3012808F4h # 518Ah SYSEVAL
  69.     # 6B7028080BEE9091h # 518Ah SYSEVAL
  70.     # BE5DC1710610C512h # 518Ah SYSEVAL
  71.     # 705D00003431A078h # 518Ah SYSEVAL
  72.     # 3D8FA26058961431h # 518Ah SYSEVAL
  73.     # 312B0514h # 518Ah SYSEVAL 
  74.     # 18F23h SYSEVAL 
  75.     DUP BYTES DROP 4 ROLL
  76.     IF ==
  77.     THEN SWAP DROP
  78.     ELSE DROP "Invalid String" DOERR
  79.     END ws STWS
  80.   \>>
  81. \>>
  82.  
  83. P2    @ ASC\->  Version 2.  To be converted by ASC\-> version 1.
  84.  
  85. "D9D20D29512BF81D0040D9D20E4A209000000007566074726636508813011920
  86. 140007FE30B9F060ED3071040CA1304EC3039916D9D2085230B9F06C2A201200
  87. 094E66716C696460235472796E676933A1B21300ED30FD5502C230C1C1632230
  88. CCD20FA0008F14660CC8FB97608403104AE7D814313016913213014117414317
  89. 414706131179A6F5C031F3AE7171AE214F8082103B6280821909EEB0808207B6
  90. 215C0160171CD5EB870A13430000D50713416985062AF8D341508813044950B9
  91. F06BBF06EFC36B9F0644230C2A201200094E66716C696460235472796E676933
  92. A1B2130B21300373"
  93.  
  94.  
  95. P3    @\->ASC.     To be converted by ASC\->.
  96. "D9D20D2951881304495032230FD5502C230A752688130ADB467FE30322306AC3
  97. 0CB916E0E30CBD30F6E30C1C1632230CCD20DC0008F14660CC8FB97608403104
  98. AE7D8143130169174147061741431311534AC6B4415141534946908D9B026155
  99. 4A6F53131F3AE731A014C161AE215F08082103A6280821939EEC08082170A621
  100. 4C161170CD56B870A18503430000D5071351796A9F8D2D02639916D9D2085230
  101. C2A209100025F4D402F426A6563647933A1B2130A2116B213033C0"
  102.  
  103. SETUP    @Automatic setup program
  104. \<< P2 P1 'ASC\->' STO
  105.     P3 ASC\-> '\->ASC' STO
  106.     { P1 P2 P3 SETUP } PURGE
  107. \>>
  108.  
  109. END
  110. (end)
  111.  
  112.  
  113. Installation instructions:
  114.  
  115. 1.  Edit the above text between (start) and (end) into a text file named
  116. CONV (for example).  
  117. Be sure that you leave the strings exactly as entered above,
  118. with no extra spaces or other invisible characters at the beginnings or
  119. ends of the lines.
  120. 2.  Set the HP 48SX into ASCII transfer mode.
  121. 3.  Using Kermit, download CONV text file to the 48, verify its checksum
  122. (6C8Ah).
  123. 4.  Execute CONV to make it the current directory.
  124. 5.  Execute SETUP.
  125. 6.  The directory CONV now contains ASC\-> and \->ASC, ready to use.
  126.  
  127. To archive the decoded versions of ASC\-> and \->ASC back on your computer,
  128. be sure to set the HP 48SX in binary transfer mode before uploading.
  129.  
  130. Disclaimers:
  131.  
  132. * Use the programs at your own risk.  Any time you delve into the SYSEVAL
  133. world, there are increased dangers.  Archive your 48 memory before 
  134. experimenting with these programs!  Also, verify the checksums of objects
  135. defined above to make sure they have been downloaded correctly, before
  136. executing ASC\->.
  137.  
  138. * I will not answer questions about how the programs work.  This is not
  139. because of any great secrecy, but rather because it's hard to give
  140. any answer that doesn't lead to more questions, and more, and more...
  141.  
  142. * 48 hackers are welcome to mine any nuggets they can from the programs,
  143. and from the fact that \->ASC is a convenient way to decompile an object.
  144.  
  145.  
  146.